package com.ruoyi.web.controller.custom;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.custom.domain.CustomRecord;
import com.ruoyi.custom.service.ICustomRecordService;

/**
 * 客户跟进Controller
 *
 * @author ruoyi
 * @date 2025-07-24
 */
@Api(tags = "客户跟进")
@RestController
@RequestMapping("/custom/record")
public class CustomRecordController extends BaseController
{
    @Autowired
    private ICustomRecordService customRecordService;

    /**
     * 查询客户跟进列表
     */
    @ApiOperation("查询客户跟进列表分页")
    @PreAuthorize("@ss.hasPermi('custom:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(CustomRecord customRecord)
    {
       // startPage();
        List<CustomRecord> list = customRecordService.selectCustomRecordList(customRecord);
        return getDataTable(list);
    }

    /**
     * 导出客户跟进列表
     */
    @PreAuthorize("@ss.hasPermi('custom:record:export')")
    @Log(title = "客户跟进", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CustomRecord customRecord)
    {
        List<CustomRecord> list = customRecordService.selectCustomRecordList(customRecord);
        ExcelUtil<CustomRecord> util = new ExcelUtil<CustomRecord>(CustomRecord.class);
        return util.exportExcel(list, "record");
    }

    /**
     * 获取客户跟进详细信息
     */
    @ApiOperation("获取客户跟进详细信息")
    @PreAuthorize("@ss.hasPermi('custom:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(customRecordService.selectCustomRecordById(id));
    }

    /**
     * 新增客户跟进
     */
    @ApiOperation("新增客户跟进")
    @PreAuthorize("@ss.hasPermi('custom:record:add')")
    @Log(title = "客户跟进", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CustomRecord customRecord)
    {
        return toAjax(customRecordService.insertCustomRecord(customRecord));
    }

    /**
     * 修改客户跟进
     */
    @ApiOperation("修改客户跟进")
    @PreAuthorize("@ss.hasPermi('custom:record:edit')")
    @Log(title = "客户跟进", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustomRecord customRecord)
    {
        return toAjax(customRecordService.updateCustomRecord(customRecord));
    }

    /**
     * 删除客户跟进
     */
    @ApiOperation("删除客户跟进")
    @PreAuthorize("@ss.hasPermi('custom:record:remove')")
    @Log(title = "客户跟进", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(customRecordService.deleteCustomRecordByIds(ids));
    }
}
